package com.lianzhihui.romeex.mvp.model;

import android.content.Context;

import com.lianzhihui.romeex.bean.RollingPoolAwardListBean;
import com.lianzhihui.romeex.net.APIConstant;
import com.lianzhihui.romeex.net.HttpManager;
import com.lianzhihui.romeex.net.HttpManagerCallback;
import com.lianzhihui.romeex.net.ResultData;
import com.lianzhihui.romeex.utils.GsonUtil;
import com.zhouyou.http.exception.ApiException;
import com.zhouyou.http.model.HttpParams;

/**
 * @ProjectName: romeex
 * @Package: com.lianzhihui.romeex.mvp.model.base
 * @ClassName: InvitationModellmp
 * @Description: java类作用描述
 * @Author: zhanghong
 * @CreateDate: 2020/11/9 18:18
 * @UpdateUser: 更新者：
 * @UpdateDate: 2020/11/9 18:18
 * @UpdateRemark: 更新说明：
 * @Version: 1.0
 */
public class MiningEarningsModelImp {


    private Context context;
    MiningEarningsModelInterface model;

    public MiningEarningsModelImp(Context context, MiningEarningsModelInterface model) {
        this.context = context;
        this.model = model;
    }

    public void requestRollingPoolAwardList(int page, int pageSize) {
        HttpParams params = new HttpParams();
        params.put("page", String.valueOf(page));
        params.put("pageSize", String.valueOf(pageSize));
        new HttpManager(context, new HttpManagerCallback() {
            @Override
            public void onSuccess(ResultData o) {
                if (o.getCode() == 200 && o.getData() != null) {
                    RollingPoolAwardListBean bean = GsonUtil.GsonToBean(o.getData(), RollingPoolAwardListBean.class);
                    model.responseRollingPoolAwardListSuccess(bean);
                } else {
                    model.onFailure();
                }
            }

            @Override
            public void onError(ApiException e) {
//                ToastUtils.showShort(MyApplication.mContext.getResources().getString(R.string.text_net_error));
                model.onFailure();
            }
        }).post(APIConstant.ROLLINGPOOL_AWARDLIST, params);
    }


}
